# -*- coding:utf-8 -*-
import multiprocessing

from logging.config import dictConfig

bind = "0.0.0.0:9090"  #9090端口是gunicorn用的端口
workers = 2  #workers是工作线程数，一般设置成：服务器CPU个数 + 1
#errorlog = 'gunicorn.error.log'
#accesslog = 'gunicorn.access.log'
loglevel = 'debug'
proc_name = 'gunicorn_project'
worker_class = 'gevent'

logconfig_dict = {
    'version':1,
    'disable_existing_loggers': False,
    'loggers':{
        "root": {"level": "INFO", "handlers": ["console"]},
        "gunicorn.error": {
            "level": "INFO",
            "handlers": ["error_file"],
            "propagate": 1,
            "qualname": "gunicorn.error"
        },

        "gunicorn.access": {
            "level": "INFO",
            "handlers": ["access_file"],
            "propagate": 0,
            "qualname": "gunicorn.access"
        }
    },
    'handlers':{
        "console": {
            "class": "logging.StreamHandler",
            "formatter": "generic",
            "stream": "sys.stdout"
        },
        "error_file": {
            "class": "logging.FileHandler",
            "formatter": "generic",
            "filename": "./log/gunicorn.error.log"
        },
        "access_file": {
            "class": "logging.handlers.RotatingFileHandler",
            "maxBytes": 1024*1024,
            "backupCount": 5,
            "formatter": "generic",
            "filename": "./log/gunicorn.access.log",
        }
    },
    'formatters':{
        "generic": {
            "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s",
            "datefmt": "[%Y-%m-%d %H:%M:%S %z]",
            "class": "logging.Formatter"
        },
        "access": {
            "format": "%(message)s",
            "class": "logging.Formatter"
        }
    }
}